package com.woniuxy.stage3demo.mapper.gy;

import com.woniuxy.stage3demo.bean.gy.UserDemo;
import com.woniuxy.stage3demo.bean.hpxbean.OrderBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.core.annotation.Order;

import java.util.List;

@Mapper
public interface OverdueOrderMapper {
    //根据订单ID查询订单详情(借款金额、产品、期限、利率)
    public OrderBean findById(@Param("id") int id);

    //根据订单的状态来查询需要提醒还款的人数
    public List<OrderBean>  findByStatus(@Param("u") UserDemo userDemo);

    //查询本月还款用户数
    @ResultType(int.class)
    @Select("select count(*)  from order_infor where status=2 and " +
            "date_format(create_time,'%Y%m')=date_format(curdate(),'%Y%m')")
    public int findCount();


    //查询本年还款用户数
    @ResultType(int.class)
    @Select("select count(*)  from order_infor where status=2 and " +
            "YEAR(create_time)=YEAR(NOW())")
    public int findCountYear();


    //查询本月的还款总金额
    @ResultType(Long.class)
    @Select("select money from order_infor where status=2 " +
            " and date_format(create_time,'%Y%m')=date_format(curdate(),'%Y%m')")
    public List<Long> findCountMoney();



    //查询本年的还款总金额
    @ResultType(Long.class)
    @Select("select money from order_infor where status=2 and " +
            "YEAR(create_time)=YEAR(NOW())")
    public List<Long> findCountMoneyYear();
}
